﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;

namespace eBrain
{
    static class Program
    {

        /// <summary>
        /// Punto di ingresso principale dell'applicazione.
        /// </summary>
        [STAThread]

        static void Main(string[] args)
        {
            string datapath = "", logpath = "", xmlfile = "", inputmode = "";

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Experiment myExperiment = null;
            ExperimentMainForm myExpWin = new ExperimentMainForm();
            TransparentLayer myTranspLayer = new TransparentLayer();

            ////Provo a sistemare un layer superiore per disegnare
            if (false)
            {
               
            }



            if (args.Length > 0)
            {
                datapath = args[0];
                logpath = args[1];
                xmlfile = args[2];
                inputmode = args[3];
            }
            else
                MessageBox.Show("Cavolo, mi manca un parametro");

            XmlDocument TestXML = new XmlDocument();

            TestXML.Load(xmlfile);

            switch (TestXML.SelectSingleNode("Experiment/Type").InnerText.ToString())
            {
                case "Saccade":
                case "Antisaccade":
                    myExperiment = new Exp_Saccade(myExpWin, datapath, logpath, inputmode);
                    break;

                case "MultipleChoice":
                    myExperiment = new Exp_MultipleChoice(myExpWin, datapath, logpath, inputmode);
                    break;

                case "SmoothPursuit":
                    myExperiment = new Exp_SmoothPursuit(myExpWin, datapath, logpath, inputmode);
                    break;

                case "VisualSearch":
                    myExperiment = new Exp_VisualSearch(myExpWin, datapath, logpath, inputmode);
                    break;

                case "CardGambling":
                    myExperiment = new Exp_Gambling(myExpWin, datapath, logpath, inputmode);
                    break;
                case "Wisconsin":
                    myExperiment = new Exp_Wisconsin(myExpWin, datapath, logpath, inputmode);
                    break;
            }

            if (myExperiment != null)
            {
                //myExpWin.HijackP3SpellerGraphics();

                myExperiment.setTranspLayer(ref myTranspLayer);
                myExperiment.StartUDPListening();
                myExperiment.StartExperiment(xmlfile, true, false);
            }


                //myExperiment.StartExperiment(xmlfile, true, false);
            Application.Run(myExpWin);


        }
    }
}
